package com.codedancer.campus.client.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.codedancer.campus.client.service.IPlateService;
import com.codedancer.campus.client.service.vo.plate.PlateVo;
import com.codedancer.campus.mapper.PlateMapper;
import com.codedancer.campus.po.Plate;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
public class PlateServiceImpl implements IPlateService {

    @Autowired
    private PlateMapper plateMapper;

    /**
     * 获取所有板块
     * @return
     */
    @Override
    public List<PlateVo> all() {
        List<Plate> plates = plateMapper.selectList(null);
        List<PlateVo> plateVos;
        plateVos = plates.stream().map(plate -> BeanUtil.copyProperties(plate,PlateVo.class)).collect(Collectors.toList());
        return plateVos;
    }
}
